home *** CD-ROM | disk | FTP | other *** search
- #include <Appearance.h>
- #include <Dialogs.h>
- #include <Fonts.h>
- #include <Gestalt.h>
- #include <TextEdit.h>
- #include "AppleEvent.h"
- #include "AppleMenu.h"
- #include "BaseEventManager.h"
- #include "BaseMenuManager.h"
- #include "BaseWindowManager.h"
- #include "EventManager.h"
- #include "EditMenu.h"
- #include "FileMenu.h"
- #include "MenuManager.h"
- #include "WindowManager.h"
- #include "Main.h"
- //#include "swarm.h"
- #include "Notice.h"
- #include "PhaseShiftNub.h"
-
-
-
-
- OSErr InitPSModule(long *ticks);
- OSErr DrawPSModule(GrafPtr deskPort, Boolean idle);
- void ClosePSModule(void);
- pascal void PhaseShiftUpdate(CGrafPtr port,RgnHandle rgn);
-
-
-
-
-
- SystemWindowEventHandlerUPP gSystemWindowEventHandlerProc = NULL;
- EventManager *gEventManager = NULL;
- MenuManager *gMenuManager = NULL;
- WindowManager *gWindowManager = NULL;
- Boolean gHasAppearance = false;
- Boolean gExitFlag = false;
-
-
- FileMenu *gFileMenu = NULL;
- PhaseShiftInfo *gPSInfo = NULL;
- //void *gSwarmData = NULL;
-
-
-
- #if GENERATINGPOWERPC
- RoutineDescriptor gPhaseShiftUpdateRD = BUILD_ROUTINE_DESCRIPTOR(uppPhaseShiftUpdateProcInfo,PhaseShiftUpdate);
- RoutineDescriptor *gPhaseShiftUpdateUPP = (RoutineDescriptor*)&gPhaseShiftUpdateRD;
- #else
- PhaseShiftUpdateUPP gPhaseShiftUpdateUPP = PhaseShiftUpdate;
- #endif
-
-
-
-
-
- void main(void)
- {
- OSStatus err;
-
-
- InitializeToolBox();
- InitializeAppleEvents();
-
- gSystemWindowEventHandlerProc = NewSystemWindowEventHandlerProc(SystemWindowEventHandler);
- gEventManager = new BaseEventManager;
- gMenuManager = new BaseMenuManager;
- gWindowManager = new BaseWindowManager;
-
- new AppleMenu;
- gFileMenu = new FileMenu;
- new EditMenu;
- DrawMenuBar();
-
- err = Gestalt(kPhaseShiftSelector,(long*)&gPSInfo);
- if (!((err == noErr) && gPSInfo && gPSInfo->registerProc))
- {
- PostNotice(kAlertStopAlert,"\pPhaseShiftNub isn't loaded!",
- "\pYou cannot run this application without the PhaseShiftNub installed.");
- ExitToShell();
- }
-
- // CallPhaseShiftRegisterProc(gPSInfo->registerProc,gPhaseShiftUpdateUPP);
- CallPhaseShiftRegisterProc(gPSInfo->registerProc,nil);
-
- {
- WindowPtr daport;
- RgnHandle rgn;
- RGBColor color = { 0, 0, 0 };
- long tic = 1;
-
- CallPhaseShiftBeginDrawProc(gPSInfo->beginDrawProc,(CGrafPtr*)&daport,&rgn);
-
- // RGBBackColor(&color);
- // EraseRect(&daport->portRect);
-
- //gSwarmData = NewSwarm(200,&daport->portRect,(WindowPtr)daport);
- err = InitPSModule(&tic);
-
- CallPhaseShiftEndDrawProc(gPSInfo->endDrawProc);
-
- if (err != noErr)
- {
- PostNotice(kAlertStopAlert,"\pInitPSModule had a problem!",
- "\pBetter luck next year.");
-
- // CallPhaseShiftUnregisterProc(gPSInfo->unregisterProc,gPhaseShiftUpdateUPP);
- CallPhaseShiftUnregisterProc(gPSInfo->unregisterProc,nil);
- ExitToShell();
- }
- }
-
- MainEventLoop();
-
- if (gPSInfo->unregisterProc)
- // CallPhaseShiftUnregisterProc(gPSInfo->unregisterProc,gPhaseShiftUpdateUPP);
- CallPhaseShiftUnregisterProc(gPSInfo->unregisterProc,nil);
-
- ClosePSModule();
-
- // if (gSwarmData)
- // {
- // DisposeSwarm(gSwarmData);
- // gSwarmData = NULL;
- // }
- }
-
-
-
-
-
- void InitializeToolBox(void)
- {
- long result;
- OSErr err;
-
-
- // Expand our heap to is maximum, this
- // will help keep fragmentation low, etc.
- MaxApplZone();
-
- // Init toolbox.
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- InitCursor();
- TEInit();
- FlushEvents(everyEvent,0);
- InitDialogs(NULL);
-
- // Check for Appearance Manager.
- err = Gestalt('appr',&result);
- gHasAppearance = ((err == noErr) && (result & 1));
- if (gHasAppearance)
- RegisterAppearanceClient();
- }
-
-
-
-
-
- void SubEventLoop(short eventMask)
- {
- EventRecord event;
- Boolean result;
-
-
- result = WaitNextEvent(eventMask,&event,0,NULL);
- gEventManager->DoDispatch(&event,false);
-
- //if (gSwarmData)
- {
- WindowPtr daport;
- RgnHandle rgn;
- // RGBColor color = { 0, 0, 0 };
-
-
- CallPhaseShiftBeginDrawProc(gPSInfo->beginDrawProc,(CGrafPtr*)&daport,&rgn);
-
- // RGBBackColor(&color);
- //SwarmIdle(gSwarmData);
- DrawPSModule((GrafPtr)daport,true);
-
- CallPhaseShiftEndDrawProc(gPSInfo->endDrawProc);
- }
- }
-
-
-
-
-
- void MainEventLoop(void)
- {
- gExitFlag = false;
- while(!gExitFlag)
- SubEventLoop(everyEvent);
- }
-
-
-
-
-
- pascal OSErr SystemWindowEventHandler(WindowPtr pWindow, EventRecord *evt, short partCode, Boolean *handled)
- {
- gEventManager->DoDispatch(evt,true);
- *handled = true;
- return noErr;
- }
-
-
-
-
-
- pascal void PhaseShiftUpdate(CGrafPtr port,RgnHandle rgn)
- {
- DrawPSModule((GrafPtr)port,false);
-
- /*
- RGBColor color = { 0, 0, 0 };
- Rect r;
-
-
- r.left = -32766;
- r.top = -32766;
- r.right = 32766;
- r.bottom = 32766;
-
- RGBBackColor(&color);
- EraseRect(&r);
- //DrawPSModule((GrafPtr)port,false);
- */
- }
-